package com.hy.erp.inventory.service;

import java.util.List ;

import javax.ejb.Stateless ;

import org.jboss.seam.ScopeType ;
import org.jboss.seam.annotations.Name ;
import org.jboss.seam.annotations.Scope ;
import org.jboss.seam.async.Schedule ;

import com.hy.enterprise.architecture.foundation.ArchitectureFoundationException;
import com.hy.enterprise.framework.service.business.AbstractBusinessService;
import com.hy.erp.inventory.dao.interfaces.IRewardsPunishmentStyleDao;
import com.hy.erp.inventory.dao.interfaces.IUserDao;
import com.hy.erp.inventory.pojo.RewardsPunishmentStyle;
import com.hy.erp.inventory.pojo.interfaces.IRewardsPunishmentStyle;
import com.hy.erp.inventory.pojo.interfaces.IUser;
import com.hy.erp.inventory.service.interfaces.IRewardsPunishmentStyleService;
/**
 * <ul>
 * <li>开发作者：汤莉</li>
 * <li>设计日期：2010-10-12；时间：下午04:46:36</li>
 * <li>字段类型：long；字段名称：serialVersionUID</li>
 * <li>设计目的：</li>
 * </ul>
 * <ul>
 * <b>修订编号：</b>
 * <li>修订日期：</li>
 * <li>修订作者：</li>
 * <li>修订原因：</li>
 * <li>修订内容：</li>
 * </ul>
 */
@Name("rewardsPunishmentStyleService")
@ Scope ( ScopeType.STATELESS )
@ Stateless
public class RewardsPunishmentStyleService
											extends
											AbstractBusinessService < IRewardsPunishmentStyle >
																					implements
																					IRewardsPunishmentStyleService
{

	
	private static final long	serialVersionUID	=
														- 7078713899138741542L ;
	/**
	 * 
	 * 构造函数
	 */
	public RewardsPunishmentStyleService()
	{
		super ( );
	}

	@ Override
	public boolean addRewardsPunishmentStyle (
												RewardsPunishmentStyle style )
	{
		if(style==null)
		{
			return true;
		}
		else
		{
			IRewardsPunishmentStyleDao dao=( IRewardsPunishmentStyleDao ) this.getDao ( IRewardsPunishmentStyle.class );
			IRewardsPunishmentStyle punishmentStyle= style;
			return dao.persist ( punishmentStyle ) ;
		}
	}

	@ Override
	public Integer removeRewardsPunishmentStyle (
													String [ ] styleIds )
	{
		if ( ( null == styleIds )
			     || ( styleIds.length == 0 ) )
			{
				return new Integer (
				                     0 ) ;
			}
			else
			{
				IRewardsPunishmentStyleDao dao=( IRewardsPunishmentStyleDao ) this.getDao ( IRewardsPunishmentStyle.class );
				return dao.remove ( styleIds );
			}
	}

	@ SuppressWarnings ( "unused" )
	@ Override
	public boolean modifyRewardsPunishmentStyle (
													RewardsPunishmentStyle style )
	{
		if ( ( null == style ) || ( null == style.getIdentifier ( ) ))
		{
			return true;
		}
		else
		{
			IRewardsPunishmentStyleDao dao=( IRewardsPunishmentStyleDao ) this.getDao ( IRewardsPunishmentStyle.class );
			IRewardsPunishmentStyle punishmentStyle= style;
			
			if ( null == punishmentStyle )
			{
				throw new ArchitectureFoundationException (
				                                            "修改用户实体数据时发生错误，所需要修改的实体在数据库中并不存在" ) ;
			}
			return (dao.merge ( punishmentStyle )!=null) ;
		}
	}

	@ Override
	public String [ ] addRewardsPunishmentStyle (
													Object [ ] objects )
	{
		IRewardsPunishmentStyleDao dao=( IRewardsPunishmentStyleDao ) this.getDao ( IRewardsPunishmentStyle.class );
		RewardsPunishmentStyle[] styles=new RewardsPunishmentStyle[objects.length];
		for ( int i =
						0 ; i < objects.length ; i ++ )
		{
			RewardsPunishmentStyle style=( RewardsPunishmentStyle ) objects[i];
			styles[i]=style;
		}
		return dao.persist ( styles ) ;
	}

	@ Override
	public List < IRewardsPunishmentStyle > getAllRewardsPunishmentStyle ( )
	{
		IRewardsPunishmentStyleDao dao=( IRewardsPunishmentStyleDao ) this.getDao ( IRewardsPunishmentStyle.class );
		return dao.find ( ) ;
	}

	@ Override
	public String [ ] modifyRewardsPunishmentStyle (
														Object [ ] objects )
	{
		if (  null == objects ) 
		{
			return null;
		}
		else
		{
			IRewardsPunishmentStyleDao dao=( IRewardsPunishmentStyleDao ) this.getDao ( IRewardsPunishmentStyle.class );
			RewardsPunishmentStyle[] types=new RewardsPunishmentStyle[objects.length];
            for(int i=0;i<objects.length;i++)
            {
            	RewardsPunishmentStyle type=( RewardsPunishmentStyle ) objects[i];
            	types[i]=type;
            }
			
			return dao.merge ( types );
		}
	}

}
